package com.note.back.pojo;


import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.groups.Default;
import java.time.LocalDateTime;
@Data
public class Note {
    private Integer id;//主键ID
    @NotEmpty
    private String name;//文章标题
    @NotEmpty
    private String description;//文章描述
    private String contentHtml;
    private String contentMd;
    private Integer category;//文章分类id
    private Integer author;//创建人ID
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;//创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;//更新时间

    // 重写 equals 方法
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Note note = (Note) o;
        return id.equals(note.id) &&
                name.equals(note.name) &&
                description.equals(note.description) &&
                (contentHtml == null ? note.contentHtml == null : contentHtml.equals(note.contentHtml)) &&
                (contentMd == null ? note.contentMd == null : contentMd.equals(note.contentMd)) &&
                (category == null ? note.category == null : category.equals(note.category)) &&
                (author == null ? note.author == null : author.equals(note.author)) &&
                (createTime == null ? note.createTime == null : createTime.equals(note.createTime)) &&
                (updateTime == null ? note.updateTime == null : updateTime.equals(note.updateTime));
    }

    // 重写 hashCode 方法
    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 31 * result + name.hashCode();
        result = 31 * result + description.hashCode();
        result = 31 * result + (contentHtml != null ? contentHtml.hashCode() : 0);
        result = 31 * result + (contentMd != null ? contentMd.hashCode() : 0);
        result = 31 * result + (category != null ? category.hashCode() : 0);
        result = 31 * result + (author != null ? author.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        return result;
    }


}